<template>
  <div class="app-container">
  <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
  </div>
</template>


<script>
import { treelistCategory } from '@/api/product/category';
  export default {
    data() {
      return {
        data: [],
        defaultProps: {
          children: 'children',
          label: 'name'
        }
      };
    },
    methods: {
      getList() {
        treelistCategory().then(({data}) => {
          this.data = data;
        });
      },
      handleNodeClick(data) {
        console.log(data);
      }
    },
  created() {
    this.getList();
  },
  };


</script>